<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div{
      height: 300px;
      width: 326px;
      border: 2px solid red;
      overflow: auto;
    }
  </style>
</head>
<body>
  <div>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
    <h1>12313123qwewqerasd</h1>
  </div>

  <script>
    var div  = document.querySelector('div')

    console.log( div.scrollHeight )  // 真实的内容的高度
    console.log( div.scrollWidth )  // 真实的内容的宽度

    div.onscroll = function() {
      // console.log(this.scrollTop)  // 滚动出去的顶部内容的高度
      console.log(this.scrollLeft)  // 滚动出去的左侧内容的高度
    }
  </script>
</body>
</html>